﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Domain.NetworkService.Behaviors.Interfaces;
using System.Diagnostics;
using System.ComponentModel.DataAnnotations;

namespace Domain.NetworkService
{
    [Serializable]
    public class Description : IDescription
    {
        public NetworkTestDescription networkTestDescription { get; set; }
        public Enum Special { get; set; }
        
        public TimeSpan Timeout { get; set; }
        public string HostNameOrIP { get; set; }
        public override string ToString()
        {
            return String.Format("{0} {1} {2} {3}",HostNameOrIP, networkTestDescription, Special, Timeout);
        }
        public override bool Equals(object obj)
        {
            if (obj != null)
            {
               Debug.WriteLine(obj.GetType());
                if (obj.GetType().GetInterface("IDescription") == typeof(IDescription))
                {
                    IDescription ntd = (IDescription)obj;
                    if (this.networkTestDescription.Equals(ntd.networkTestDescription) &&
                        this.Special.Equals(ntd.Special))
                    {
                        return true;
                    }
                }
            }
            return false;
        }

        public override int GetHashCode()
        {
            return (this.networkTestDescription.GetHashCode()) ^
                   (this.Special.GetHashCode());
        }

        public static bool operator ==(Description a, Description b)
        {
            if (System.Object.ReferenceEquals(a, b))
            {
                return true;
            }
            if (((object)a == null) || ((object)b == null))
            {
                return false;
            }
            return a.networkTestDescription == b.networkTestDescription &&
                   a.Special == b.Special;
        }
        public static bool operator !=(Description a, Description b)
        {
            return !(a == b);
        }
    }
}
